package org.jdcenter.rmi;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdcenter.rmi.abs.Server;
import org.jdcenter.rmi.abs.ServerException;
import org.jdcenter.rmi.abs.ServerFactory;
import org.jdcenter.rmi.abs.URLException;
import org.jdcenter.rmi.impl.RMIFactory;

public class RMIServerImpl{
	
	private static Log log = LogFactory.getLog(RMIServerImpl.class);
	
	private static ServerFactory serverFactory = null;
	
	private static Map<String,Server> path_servers = null;
	private static Map<RMIWrap,Server> syncWrap_servers = null;
	private static Map<RMIWrap,Server> asyncWrap_servers = null;
	
	static{
		try {
			serverFactory = RMIFactory.getServerFactory("jds.rmi.properties");
		} catch (IOException e) {
			log.error(e);
		}
		path_servers = new ConcurrentHashMap<String,Server>();
		syncWrap_servers = new ConcurrentHashMap<RMIWrap,Server>();
		asyncWrap_servers = new ConcurrentHashMap<RMIWrap,Server>();
	}
	
	public static void registerSyncJRMPAuto(String rmiPath,Object obj) throws URLException, ServerException{
		
	}
	
	public static void registerSyncIIOPAuto(String rmiPath,Object obj) throws URLException, ServerException{
		
	}
	
	public static void registerAsyncJRMPAuto(String rmiPath,Object obj) throws URLException, ServerException{
		
	}
	
	public static void registerAsyncIIOPAuto(String rmiPath,Object obj) throws URLException, ServerException{
		
	}
	
	public static void registerSyncJRMPCustom(String rmiPath,RMIWrap wrap) throws URLException, ServerException{
		
	}
	
	public static void registerSyncIIOPCustom(String rmiPath,RMIWrap wrap) throws URLException, ServerException{
		
	}
	
	public static void registerAsyncJRMPCustom(String rmiPath,RMIWrap wrap) throws URLException, ServerException{
		Server server = serverFactory.createAsync(rmiPath, wrap);
		server.run();
		path_servers.put(rmiPath, server);
		asyncWrap_servers.put(wrap, server);
	}
	
	public static void registerAsyncIIOPCustom(String rmiPath,RMIWrap wrap){
		
	}

}
